package com.zhou.message.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.zhou.util.ObjectUtil;
import com.zhou.message.dao.ReceiveMessage;
import com.zhou.message.mapper.ReceiveMessageMapper;
import com.zhou.message.service.ReceiveMessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collection;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lang.zhou
 * @since 2023-03-01
 */
@Service
public class ReceiveMessageServiceImpl extends ServiceImpl<ReceiveMessageMapper, ReceiveMessage> implements ReceiveMessageService {

    @Override
    public void deleteReceiveMessage(Collection<Long> idList) {
        if(ObjectUtil.isNotEmpty(idList)){
            LambdaUpdateWrapper<ReceiveMessage> w = new LambdaUpdateWrapper<>();
            w.in(ReceiveMessage::getId,idList);
            w.set(ReceiveMessage::getDeleteFlag,1);
            update(w);
        }
    }

    @Override
    public void updateReceiveMessageStatus(Integer status, Collection<Long> idList) {
        if(ObjectUtil.isNotEmpty(idList)){
            LambdaUpdateWrapper<ReceiveMessage> w = new LambdaUpdateWrapper<>();
            w.in(ReceiveMessage::getId,idList);
            w.set(ReceiveMessage::getStatus,status);
            update(w);
        }
    }

}
